from pydantic import BaseSettings
from typing import Optional
import os


class Settings(BaseSettings):
    """应用配置设置"""
    
    # 应用基本配置
    app_name: str = "UI自动化管理工具"
    app_version: str = "1.0.0"
    
    # 脚本存储配置
    scripts_dir: str = "scripts"
    max_scripts: int = 1000
    
    # Playwright配置
    browser_type: str = "chromium"  # chromium, firefox, webkit
    headless: bool = False
    timeout: int = 30000  # 毫秒
    
    # PyQt6界面配置
    window_width: int = 1200
    window_height: int = 800
    theme: str = "light"  # light, dark
    
    # 日志配置
    log_level: str = "INFO"
    log_file: str = "logs/app.log"
    
    class Config:
        env_file = ".env"
        env_file_encoding = 'utf-8'


def get_settings() -> Settings:
    """获取配置实例"""
    return Settings()